<template lang="html">
  <div v-if="error" class="error-text">{{error}}</div>
  <div v-else>
    <stage-header :userInfo="userInfo"></stage-header>
    <stage-normal :normalData="normalData"></stage-normal>
    <stage-read :readData="readData"></stage-read>
    <stage-grow :growData="growAllData" v-if="growAllData.classtest"></stage-grow>
    <stage-sum v-if="abilityData.length" :testData="testData" :typeData="typeData" :abilityData="abilityData"
               :userInfo="userInfo"></stage-sum>
    <div class="footer-box"></div>
  </div>
</template>

<script>
  import StageHeader from '@/components/stageHeader'
  import StageNormal from '@/components/stageNormal'
  import StageRead from '@/components/stageRead'
  import StageGrow from '@/components/stageGrow'
  import StageSum from '@/components/stageSum'
  // import axios from '~common/assets/js/axios.js'
  export default {
    data () {
      return {
        stageBaseData: [], // 基础数据
        userInfo: {}, // 用户信息
        error: '',  // 错误数据
        readData: {}, // 晨读数据
        normalData: {},  // 习惯养成
        testData: {}, // 总测评数据
        typeData: [], // 我的分数各项数据
        abilityData: [], // 能力模型数据
        growAllData: [] // 成长模块数据
      }
    },
    components: {
      StageHeader,
      StageNormal,
      StageRead,
      StageGrow,
      StageSum
    },
    mounted () {
      this.init()
    },
    methods: {
      init () {  // 获取数据
             // let url = 'https://easy-mock.com/mock/5ae1918027180b659e7905ce/teacher/teacher'
          let url = '/libarts/StudyReport/shareStageTestTeacher'  // 测试接口
        let userInfo = window.userInfo
        this.$axios.post(url, {
          stuId: userInfo.stuId,
          courseId: userInfo.courseId,
          planId: userInfo.planId
        }).then((res) => {
          if (res.data.stat === 1) {
            let data = res.data
            this.stageBaseData = data.data
            this.userInfo = this.stageBaseData.user
            this.normalData = this.stageBaseData.class
            this.readData = this.stageBaseData.mornread
            this.testData = this.stageBaseData.stagetestscore
            this.typeData = this.stageBaseData.testtype
            this.abilityData = this.stageBaseData.abilitymodel
            this.growAllData = this.stageBaseData.growdata
          } else {
            this.error = '报告未生成'
          }
        }).catch(() => {
          console.log('record error')
        })
      }
    }

  }
</script>
<style type="text/css">
  .footer-box {
    width: 100%;
    height: 3.75rem;
    background: url('../assets/img/bottom_bg.png') no-repeat;
    background-size: 100% 100%;
  }

  @media screen and (min-width: 768px) {
    html {
      max-width: 750px;
      font-size: 100px !important;
      margin: 0 auto;
    }
  }
  .message-text-distance {
    display: block;
    text-align: left;
  }
  .error-text{
    font-size: .48rem;
    text-align: center;
    color:#f96900;
    font-weight: 500;
    margin-top: 2rem;
  }
</style>
